package com.example.zhihulogin.slice;

import com.example.zhihulogin.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.Color;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.*;
import ohos.agp.components.element.Element;
import ohos.agp.components.element.ShapeElement;

import java.util.HashSet;
import java.util.Set;

public class MainAbilitySlice extends AbilitySlice {
    private Set<String> selectedSet = new HashSet<>();

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        TextField input_phone = (TextField) findComponentById(ResourceTable.Id_input_phone);
        TextField input_password = (TextField) findComponentById(ResourceTable.Id_input_password);
        Button login = (Button) findComponentById(ResourceTable.Id_login);
        Checkbox save_password = (Checkbox) findComponentById(ResourceTable.Id_save_password);
        save_password.setCheckedStateChangedListener((component, state) -> {
            if (state) {
                selectedSet.add(input_password.getText().toString());
            } else {
                selectedSet.remove(input_password.getText().toString());
            }
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
